#pragma once
#include <d3d9.h>
#include "Utility\Matrix.h"

class Geometry;
class DxShader;

class DxRenderer
{
public:
	DxRenderer(void);
	~DxRenderer(void);

	bool CreateDevice(HWND hwnd);
	void BeginDraw();
	void DrawGeometry(Geometry* geometry,const Matrix& mWorld);
	void EndDraw();

	static inline DxRenderer* GetInstance();

	IDirect3DDevice9* GetDevice() { return m_pDevice; }

	void SetWorld(const Matrix& mWorld);
	void SetView(const Matrix& mView);
	void SetPerspective(float fFov, float fNear, float fFar);
	bool SetShaderWorldViewProjection();
	bool SetShaderWorld(const Matrix& mWorld);

	const Matrix& GetProjection() { return m_mProjection; }
	float GetScreenWidth() { return m_fScreenWidth; }
	float GetScreenHeight() { return m_fScreenHeight; }

protected:
	IDirect3D9*			m_pD3D;
	IDirect3DDevice9*	m_pDevice;
	Matrix				m_mProjection;
	Matrix				m_mView;
	Matrix				m_mWorldViewProjection;
	float				m_fScreenWidth;
	float				m_fScreenHeight;
	

	static DxRenderer* sm_pRenderer;

};

DxRenderer* DxRenderer::GetInstance()
{
	if( !sm_pRenderer )
		sm_pRenderer = new DxRenderer();

	return sm_pRenderer;
}